<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of convMax</title>
  <meta name="keywords" content="convMax">
  <meta name="description" content="Extremely fast 2D image convolution with a max filter.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html channels -->
<h1>convMax
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Extremely fast 2D image convolution with a max filter.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function J = convMax( I, r, nomex ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Extremely fast 2D image convolution with a max filter.

 For each location computes J(y,x) = max(max(I(y-r:y+r,x-r:x+r))). The
 filtering is constant time per-window, independent of r. First, the
 filtering is separable, which brings the complexity down to O(r) per
 window from O(r*r). To bring the implemention down to constant time
 (independent of r) we use the van Herk/Gil-Werman algorithm. Ignoring
 boundaries, just 3 max operations are need per-window regardless of r.
  http://www.leptonica.com/grayscale-morphology.html#FAST-IMPLEMENTATION

 The output is exactly equivalent to the following Matlab operations:
  I=padarray(I,[r r],'replicate','both'); [h,w,d]=size(I); J=I;
  for z=1:d, for x=r+1:w-r, for y=r+1:h-r
        J(y,x,z) = max(max(I(y-r:y+r,x-r:x+r,z))); end; end; end
  J=J(r+1:h-r,r+1:w-r,:);
 The computation, however, is an order of magnitude faster than the above.

 USAGE
  J = convMax( I, r, [nomex] )

 INPUTS
  I      - [hxwxk] input k channel single image
  r      - integer filter radius or radii along y and x
  nomex  - [0] if true perform computation in matlab (for testing/timing)

 OUTPUTS
  J      - [hxwxk] max image

 EXAMPLE
  I = single(imResample(imread('cameraman.tif'),[480 640]))/255;
  r = 5; % set parameter as desired
  tic, J1=convMax(I,r); toc % mex version (fast)
  tic, J2=convMax(I,r,1); toc % matlab version (slow)
  figure(1); im(J1); figure(2); im(abs(J2-J1));

 See also conv2, <a href="convTri.html" class="code" title="function J = convTri( I, r, s, nomex )">convTri</a>, <a href="convBox.html" class="code" title="function J = convBox( I, r, s, nomex )">convBox</a>

 Piotr's Computer Vision Matlab Toolbox      Version 3.00
 Copyright 2014 Piotr Dollar &amp; Ron Appel.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
